package com.liudaolunhui.interfaces;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class TimeProxy implements InvocationHandler {
	
	public  TimeProxy(Object target) {
		this.target=target;
	}
	public Object target;
	@Override
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		long beginTime = System.currentTimeMillis();
		System.out.println("汽车开始行驶");
		method.invoke(target);
		System.out.println("汽车结束行驶");
		long endTime = System.currentTimeMillis();
		System.out.println("行驶时间:"+(endTime-beginTime));
		return null;
	}

}
